<!DOCTYPE html>

































































<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" type="image/x-icon" href="../../../favicon.ico" />
<title>JNI Tips | Android Developers</title>
<link href="../../../assets/android-developer-docs-devguide.css" rel="stylesheet" type="text/css" />
<script src="../../../assets/search_autocomplete.js" type="text/javascript"></script>
<script src="../../../assets/jquery-resizable.min.js" type="text/javascript"></script>
<script src="../../../assets/android-developer-docs.js" type="text/javascript"></script>
<script src="../../../assets/prettify.js" type="text/javascript"></script>
<script type="text/javascript">
  setToRoot("../../../");
</script>
<noscript>
  <style type="text/css">
    html,body{overflow:auto;}
    #body-content{position:relative; top:0;}
    #doc-content{overflow:visible;border-left:3px solid #666;}
    #side-nav{padding:0;}
    #side-nav .toggle-list ul {display:block;}
    #resize-packages-nav{border-bottom:3px solid #666;}
  </style>
</noscript>
</head>
<body class="gc-documentation">

  <div id="header">
      <div id="headerLeft">
          <a href="../../../index.html" tabindex="-1"><img
              src="../../../assets/images/bg_logo.png" alt="Android Developers" /></a>
          <ul id="header-tabs" class="guide">
    
	<li id="home-link"><a href="../../../offline.html">
	
		<span class="en">Home</span>
		<span style="display:none" class="de">Startseite</span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ホーム</span>
		<span style="display:none" class="zh-CN">主页</span>
		<span style="display:none" class="zh-TW">首頁</span>
	
	</a></li>
	<li id="sdk-link"><a href="../../../sdk/index.html">
		<span class="en">SDK</span>
	</a></li>
	<li id="guide-link"><a href="../../../guide/index.html" onClick="return loadLast('guide')">
	
		<span class="en">Dev Guide</span>
		<span style="display:none" class="de">Handbuch</span>
		<span style="display:none" class="es">Guía</span>
		<span style="display:none" class="fr">Guide</span>
		<span style="display:none" class="it">Guida</span>
		<span style="display:none" class="ja">開発ガイド</span>
		<span style="display:none" class="zh-CN">开发人员指南</span>
		<span style="display:none" class="zh-TW">開發指南</span>
	
	</a></li>
	<li id="reference-link"><a href="../../../reference/packages.html" onClick="return loadLast('reference')">
	
		<span class="en">Reference</span>
		<span style="display:none" class="de">Referenz</span>
		<span style="display:none" class="es">Referencia</span>
		<span style="display:none" class="fr">Référence</span>
		<span style="display:none" class="it">Riferimento</span>
		<span style="display:none" class="ja">リファレンス</span>
		<span style="display:none" class="zh-CN">参考</span>
		<span style="display:none" class="zh-TW">參考資料</span>
	
	</a></li>
	<li id="resources-link"><a href="../../../resources/index.html" onClick="return loadLast('resources')">
	
		<span class="en">Resources</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
    		<span style="display:none" class="ja"></span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li id="videos-link"><a href="../../../videos/index.html" onClick="return loadLast('videos')">
	
		<span class="en">Videos</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ビデオ</span>
		<span style="display:none" class="zh-CN"></span>
		<span style="display:none" class="zh-TW"></span>
	
	</a></li>
	<li><a href="http://android-developers.blogspot.com" onClick="return requestAppendHL(this.href)">
	
		<span class="en">Blog</span>
		<span style="display:none" class="de"></span>
		<span style="display:none" class="es"></span>
		<span style="display:none" class="fr"></span>
		<span style="display:none" class="it"></span>
		<span style="display:none" class="ja">ブログ</span>
		<span style="display:none" class="zh-CN">博客</span>
		<span style="display:none" class="zh-TW">網誌</span>
	
	</a></li>


     
</ul>
     
      </div>
      <div id="headerRight">
          <div id="headerLinks">
          
          <a href="http://www.android.com">Android.com</a>
          </div>
  <div id="search" >
      <div id="searchForm">
          <form accept-charset="utf-8" class="gsc-search-box" 
                onsubmit="return submit_search()">
            <table class="gsc-search-box" cellpadding="0" cellspacing="0"><tbody>
                <tr>
                  <td class="gsc-input">
                    <input id="search_autocomplete" class="gsc-input" type="text" size="33" autocomplete="off"
                      title="search developer docs" name="q"
                      value="search developer docs"
                      onFocus="search_focus_changed(this, true)"
                      onBlur="search_focus_changed(this, false)"
                      onkeydown="return search_changed(event, true, '../../../')"
                      onkeyup="return search_changed(event, false, '../../../')" />
                  <div id="search_filtered_div" class="no-display">
                      <table id="search_filtered" cellspacing=0>
                      </table>
                  </div>
                  </td>
                  <td class="gsc-search-button">
                    <input type="submit" value="Search" title="search" id="search-button" class="gsc-search-button" />
                  </td>
                  <td class="gsc-clear-button">
                    <div title="clear results" class="gsc-clear-button">&nbsp;</div>
                  </td>
                </tr></tbody>
              </table>
          </form>
      </div><!-- searchForm -->
  </div><!-- search -->
      </div><!-- headerRight -->
      <script type="text/javascript">
        <!--  
        changeTabLang(getLangPref());
        //-->
      </script>
  </div><!-- header -->

  <div class="g-section g-tpl-240" id="body-content">
    <div class="g-unit g-first" id="side-nav">
      <div id="devdoc-nav">
<ul>

  <li>
    <h2><span class="en">Android Basics</span>
        <span class="de" style="display:none">Einführung in Android</span>
        <span class="es" style="display:none">Información básica sobre Android</span>
        <span class="fr" style="display:none">Présentation d'Android</span>
        <span class="it" style="display:none">Nozioni di base su Android</span>
        <span class="ja" style="display:none">Android の基本</span>
        <span class="zh-CN" style="display:none">Android 基础知识</span>
        <span class="zh-TW" style="display:none">Android 簡介</span>
    </h2>
    <ul>
      <li><a href="../../../guide/basics/what-is-android.html">
        <span class="en">What Is Android?</span>
        <span class="de" style="display:none">Was ist Android?</span>
        <span class="es" style="display:none">¿Qué es Android?</span>
        <span class="fr" style="display:none">Qu'est-ce qu'Android&nbsp;?</span>
        <span class="it" style="display:none">Che cos'è Android?</span>
        <span class="ja" style="display:none">Android とは</span>
        <span class="zh-CN" style="display:none">Android 是什么？</span>
        <span class="zh-TW" style="display:none">什麼是 Android？</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals.html">
        <span class="en">Application Fundamentals</span>
        <span class="de" style="display:none">Anwendungsgrundlagen</span>
        <span class="es" style="display:none">Fundamentos de las aplicaciones</span>
        <span class="fr" style="display:none">Principes de base des applications</span>
        <span class="it" style="display:none">Concetti fondamentali sulle applicazioni</span>
        <span class="ja" style="display:none">開発の基礎</span>
        <span class="zh-CN" style="display:none">应用程序基础</span>
        <span class="zh-TW" style="display:none">應用程式基本原理</span>
      </a></li>

  <!--  <li><a style="color:gray;">The Android SDK</a></li> -->
  <!--  <li><a style="color:gray;">Walkthrough for Developers</a></li> -->
      <!-- quick overview of what it's like to develop on Android -->
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Framework Topics</span>
      <span class="de" style="display:none">Framework-Themen</span>
      <span class="es" style="display:none">Temas sobre el framework</span>
      <span class="fr" style="display:none">Thèmes relatifs au framework</span>
      <span class="it" style="display:none">Argomenti relativi al framework</span>
      <span class="ja" style="display:none">フレームワーク トピック</span>
      <span class="zh-CN" style="display:none">框架主题</span>
      <span class="zh-TW" style="display:none">架構主題</span>
    </h2>
    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/activities.html">
          <span class="en">Activities</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/fragments.html">
            <span class="en">Fragments</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/loaders.html">
            <span class="en">Loaders</span>
          </a></li>
          <li><a href="../../../guide/topics/fundamentals/tasks-and-back-stack.html">
            <span class="en">Tasks and Back Stack</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/fundamentals/services.html">
          <span class="en">Services</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/fundamentals/bound-services.html">
            <span class="en">Bound Services</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/topics/providers/content-providers.html">
            <span class="en">Content Providers</span>
          </a></li>
      <li><a href="../../../guide/topics/intents/intents-filters.html">
            <span class="en">Intents and Intent Filters</span>
          </a></li>
      <li><a href="../../../guide/topics/fundamentals/processes-and-threads.html">
            <span class="en">Processes and Threads</span>
          </a></li>
    </ul>


    <ul>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/ui/index.html">
            <span class="en">User Interface</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/ui/declaring-layout.html">
               <span class="en">XML Layouts</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/ui-events.html">
                <span class="en">Input Events</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/menus.html">
               <span class="en">Menus</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/actionbar.html">
               <span class="en">Action Bar</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/dialogs.html">
                <span class="en">Dialogs</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/ui/notifiers/index.html">
                <span class="en">Notifications</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/ui/notifiers/toasts.html">
                <span class="en">Toast Notifications</span>
              </a></li>
              <li><a href="../../../guide/topics/ui/notifiers/notifications.html">
                <span class="en">Status Bar Notifications</span>
              </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/topics/ui/drag-drop.html">
                <span class="en">Drag and Drop</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/themes.html">
                <span class="en">Styles and Themes</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/custom-components.html">
                <span class="en">Custom Components</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/binding.html">
                <span class="en">Binding to Data with AdapterView</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/layout-objects.html">
                <span class="en">Common Layout Objects</span>
              </a></li>
          <li><a href="../../../guide/topics/ui/how-android-draws.html">
                <span class="en">How Android Draws Views</span>
              </a></li>
        </ul>
      </li><!-- end of User Interface -->

      <li class="toggle-list">
        <div><a href="../../../guide/topics/resources/index.html">
               <span class="en">Application Resources</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/resources/providing-resources.html">
                <span class="en">Providing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/accessing-resources.html">
                <span class="en">Accessing Resources</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/runtime-changes.html">
                <span class="en">Handling Runtime Changes</span>
              </a></li>
          <li><a href="../../../guide/topics/resources/localization.html">
                <span class="en">Localization</span>
              </a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/topics/resources/available-resources.html">
              <span class="en">Resource Types</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/topics/resources/animation-resource.html">Animation</a></li>
              <li><a href="../../../guide/topics/resources/color-list-resource.html">Color State List</a></li>
              <li><a href="../../../guide/topics/resources/drawable-resource.html">Drawable</a></li>
              <li><a href="../../../guide/topics/resources/layout-resource.html">Layout</a></li>
              <li><a href="../../../guide/topics/resources/menu-resource.html">Menu</a></li>
              <li><a href="../../../guide/topics/resources/string-resource.html">String</a></li>
              <li><a href="../../../guide/topics/resources/style-resource.html">Style</a></li>
              <li><a href="../../../guide/topics/resources/more-resources.html">More Types</a></li>
            </ul>
          </li><!-- end of resource types -->
        </ul>
      </li><!-- end of app resources -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/data/data-storage.html">
            <span class="en">Data Storage</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/data/backup.html">
                <span class="en">Data Backup</span>
              </a>
            </li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/security/security.html">
            <span class="en">Security and Permissions</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/manifest/manifest-intro.html">
          <span class="en">The AndroidManifest.xml File</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/topics/manifest/action-element.html">&lt;action&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-element.html">&lt;activity&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/activity-alias-element.html">&lt;activity-alias&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/application-element.html">&lt;application&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/category-element.html">&lt;category&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/compatible-screens-element.html">&lt;compatible-screens&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/data-element.html">&lt;data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/grant-uri-permission-element.html">&lt;grant-uri-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/instrumentation-element.html">&lt;instrumentation&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/intent-filter-element.html">&lt;intent-filter&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/manifest-element.html">&lt;manifest&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/meta-data-element.html">&lt;meta-data&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/path-permission-element.html">&lt;path-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-element.html">&lt;permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-group-element.html">&lt;permission-group&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/permission-tree-element.html">&lt;permission-tree&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/provider-element.html">&lt;provider&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/receiver-element.html">&lt;receiver&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/service-element.html">&lt;service&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-gl-texture-element.html">&lt;supports-gl-texture&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/supports-screens-element.html">&lt;supports-screens&gt;</a></li><!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-configuration-element.html">&lt;uses-configuration&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-feature-element.html">&lt;uses-feature&gt;</a></li> <!-- ##api level 4## -->
          <li><a href="../../../guide/topics/manifest/uses-library-element.html">&lt;uses-library&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-permission-element.html">&lt;uses-permission&gt;</a></li>
          <li><a href="../../../guide/topics/manifest/uses-sdk-element.html">&lt;uses-sdk&gt;</a></li>
        </ul>
      </li><!-- end of the manifest file -->
    </ul>

    <ul>
    <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/index.html">
            <span class="en">Graphics</span>
          </a><span class="new-child">new!</span></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/2d-graphics.html">
              <span class="en">Canvas and Drawables</span></a></li>
          <li><a href="../../../guide/topics/graphics/hardware-accel.html">
              <span class="en">Hardware Acceleration</span></a>
            <span class="new">new!</span></li>
          <li><a href="../../../guide/topics/graphics/opengl.html">
              <span class="en">OpenGL</span>
            </a><span class="new">updated</span></li>
        </ul>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/graphics/animation.html">
            <span class="en">Animation</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/topics/graphics/prop-animation.html">
              <span class="en">Property Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/view-animation.html">
              <span class="en">View Animation</span></a></li>
          <li><a href="../../../guide/topics/graphics/drawable-animation.html">
              <span class="en">Drawable Animation</span></a></li>
        </ul>
      </li>
      <li class="toggle-list">
	        <div><a href="../../../guide/topics/renderscript/index.html">
	            <span class="en">RenderScript</span>
	          </a></div>
	        <ul>
	          <li><a href="../../../guide/topics/renderscript/graphics.html">
	                <span class="en">Graphics</span>
	              </a>
	          </li>
	          <li><a href="../../../guide/topics/renderscript/compute.html">
	                <span class="en">Compute</span>
	              </a>
	          </li>
	        </ul>
  	  </li>

      <li class="toggle-list">
          <div><a href="../../../guide/topics/media/index.html">
            <span class="en">Multimedia and Camera</span>
          </a><span class="new">updated</span></div>
          <ul>
            <li><a href="../../../guide/topics/media/mediaplayer.html">
                  <span class="en">Media Playback</span></a>
                </li>
            <li><a href="../../../guide/topics/media/jetplayer.html">
                  <span class="en">JetPlayer</span></a>
                </li>
            <li><a href="../../../guide/topics/media/camera.html">
                  <span class="en">Camera</span></a>
                  <span class="new">new!</span>
                </li>
            <li><a href="../../../guide/topics/media/audio-capture.html">
                  <span class="en">Audio Capture</span></a>
                </li>
          </ul>
      </li>
      <li>
        <a href="../../../guide/topics/clipboard/copy-paste.html">
            <span class="en">Copy and Paste</span>
        </a></li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Sensors</a></div>
          <ul>
            <li><a style="color:gray;">Camera</a></li>
            <li><a style="color:gray;">Compass</a></li>
            <li><a style="color:gray;">Accelerometer</a></li>
          </ul>
      </li> -->
      <li class="toggle-list">
        <div><a href="../../../guide/topics/location/index.html">
               <span class="en">Location and Maps</span>
             </a></div>
        <ul>
          <li><a href="../../../guide/topics/location/obtaining-user-location.html">
                <span class="en">Obtaining User Location</span>
              </a></li>
        </ul>
      </li>
  <!--<li class="toggle-list">
        <div><a style="color:gray;">Wireless Controls</a></div>
          <ul>
            <li><a style="color:gray;">Wi-Fi</a></li>
          </ul>
      </li> -->
  <!--<li><a style="color:gray;">Localization</a></li>  -->
      <li><a href="../../../guide/topics/appwidgets/index.html">
            <span class="en">App Widgets</span></a>
          </li>
      <li><a href="../../../guide/topics/wireless/bluetooth.html">
            <span class="en">Bluetooth</span></a>
          </li>
      <li><a href="../../../guide/topics/nfc/index.html">
            <span class="en">Near Field Communication</span>
          </a></li>
      <li class="toggle-list">
          <div><a href="../../../guide/topics/usb/index.html">
            <span class="en">USB</span></a>
          </div>
            <ul>
              <li><a href="../../../guide/topics/usb/accessory.html">Accessory</a></li>
              <li><a href="../../../guide/topics/usb/host.html">Host</a></li>
              <li><a href="../../../guide/topics/usb/adk.html">Open Accessory Dev Kit</a></li>
            </ul>
          </li>

       <li><a href="../../../guide/topics/network/sip.html">
            <span class="en">Session Initiation Protocol</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/topics/search/index.html">
            <span class="en">Search</span>
          </a></div>
          <ul>
            <li><a href="../../../guide/topics/search/search-dialog.html">Creating a Search Interface</a></li>
            <li><a href="../../../guide/topics/search/adding-recent-query-suggestions.html">Adding Recent Query Suggestions</a></li>
            <li><a href="../../../guide/topics/search/adding-custom-suggestions.html">Adding Custom Suggestions</a></li>
            <li><a href="../../../guide/topics/search/searchable-config.html">Searchable Configuration</a></li>
          </ul>
      </li>
      <li><a href="../../../guide/topics/admin/device-admin.html">
            <span class="en">Device Administration</span></a>
      </li>
      <li class="toggle-list">
           <div>
                <a href="../../../guide/topics/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/topics/testing/testing_android.html">
                <span class="en">Testing Fundamentals</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/activity_testing.html">
                <span class="en">Activity Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/contentprovider_testing.html">
                <span class="en">Content Provider Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/service_testing.html">
                <span class="en">Service Testing</span></a>
              </li>
              <li>
                <a href="../../../guide/topics/testing/what_to_test.html">
                <span class="en">What To Test</span></a>
              </li>
           </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2>
      <span class="en">Android Market Topics</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/licensing.html">
          <span class="en">Application Licensing</span></a>
      </li>
      <li class="toggle-list">
        <div><a href="../../../guide/market/billing/index.html">
            <span class="en">In-app Billing</span></a>
        </div>
        <ul>
          <li><a href="../../../guide/market/billing/billing_overview.html">
              <span class="en">In-app Billing Overview</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_integrate.html">
              <span class="en">Implementing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_best_practices.html">
              <span class="en">Security and Design</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_testing.html">
              <span class="en">Testing In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_admin.html">
              <span class="en">Administering In-app Billing</span></a>
          </li>
          <li><a href="../../../guide/market/billing/billing_reference.html">
              <span class="en">In-app Billing Reference</span></a>
          </li>
        </ul>
      </li>
      <li><a href="../../../guide/appendix/market-filters.html">
          <span class="en">Market Filters</span></a>
      </li>
      <li><a href="../../../guide/market/publishing/multiple-apks.html">
          <span class="en">Multiple APK Support</span></a>
      </li>
    </ul>
  </li>


  <li>
    <h2><span class="en">Developing</span>
               <span class="de" style="display:none">Entwicklung</span>
               <span class="es" style="display:none">Desarrollo</span>
               <span class="fr" style="display:none">Développement</span>
               <span class="it" style="display:none">Sviluppo</span>
               <span class="ja" style="display:none">開発</span>
               <span class="zh-CN" style="display:none">开发</span>
               <span class="zh-TW" style="display:none">開發</span>
    </h2>
    <ul>
  <!--<li><a href="">Developing for Android</a></li>
      signing, upgrading, selecting a package name, select device profile, touch, trackball, dpad available, etc. -->
      <li>
        <a href="../../../guide/developing/index.html">
        <span class="en">Introduction</span></a>
      </li>

      <li class="toggle-list">
        <div>
           <a href="../../../guide/developing/devices/index.html">
                <span class="en">Managing Virtual Devices</span>
            </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/devices/managing-avds.html">
              <span class="en">With AVD Manager</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/devices/managing-avds-cmdline.html">
              <span class="en">From the Command Line</span>
            </a>
          </li>
          <li>
           <a href="../../../guide/developing/devices/emulator.html">
                <span class="en">Using the Android Emulator</span>
            </a>
          </li>
        </ul>
      </li>
      <li>
        <a href="../../../guide/developing/device.html">
          <span class="en">Using Hardware Devices</span>
        </a>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/projects/index.html">
            <span class="en">Managing Projects</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/projects/projects-eclipse.html">
              <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/projects/projects-cmdline.html">
                <span class="en">From the Command Line</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/building/index.html">
            <span class="en">Building and Running</span>
          </a>
        </div>
        <ul>
          <li><a href="../../../guide/developing/building/building-eclipse.html">
            <span class="en">From Eclipse with ADT</span>
          </a></li>
          <li><a href="../../../guide/developing/building/building-cmdline.html">
            <span class="en">From the Command Line</span></a></li>
        </ul>
      </li>

      <li class="toggle-list">
        <div>
          <a href="../../../guide/developing/debugging/index.html">
            <span class="en">Debugging</span>
          </a>
        </div>
        <ul>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects.html">
                <span class="en">From Eclipse with ADT</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-projects-cmdline.html">
                <span class="en">From Other IDEs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/ddms.html">
              <span class="en">Using DDMS</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-log.html">
                <span class="en">Reading and Writing Logs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-ui.html">
                <span class="en">Debugging and Profiling UIs</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-tracing.html">
                <span class="en">Profiling with Traceview and dmtracedump</span>
            </a>
          </li>
          <li>
            <a href="../../../guide/developing/debugging/debugging-devtools.html">
                <span class="en">Using the Dev Tools App</span>
            </a>
          </li>
        </ul>
      </li>

      <li class="toggle-list">
           <div>
                <a href="../../../guide/developing/testing/index.html">
                   <span class="en">Testing</span>
               </a>
           </div>
           <ul>
              <li>
                <a href="../../../guide/developing/testing/testing_eclipse.html">
                  <span class="en">From Eclipse with ADT</span>
                </a>
              </li>

              <li>
                <a href="../../../guide/developing/testing/testing_otheride.html">
                  <span class="en">From Other IDEs</span>
                </a>
              </li>
           </ul>
         </li>

         <li class="toggle-list">
        <div><a href="../../../guide/developing/tools/index.html">
            <span class="en">Tools</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/developing/tools/adb.html">adb</a></li>
          <li><a href="../../../guide/developing/tools/adt.html">ADT</a></li>
          <li><a href="../../../guide/developing/tools/android.html">android</a></li>
          <li><a href="../../../guide/developing/tools/bmgr.html">bmgr</a>
          <li><a href="../../../guide/developing/tools/dmtracedump.html">dmtracedump</a></li>
          <li><a href="../../../guide/developing/tools/draw9patch.html">Draw
          9-Patch</a></li>
          <li><a href="../../../guide/developing/tools/emulator.html">Emulator</a></li>
          <li><a href="../../../guide/developing/tools/etc1tool.html">etc1tool</a></li>
          <li><a href="../../../guide/developing/tools/hierarchy-viewer.html">Hierarchy Viewer</a></li>
          <li><a href="../../../guide/developing/tools/hprof-conv.html">hprof-conv</a></li>
          <li><a href="../../../guide/developing/tools/layoutopt.html">layoutopt</a></li>
          <li><a href="../../../guide/developing/tools/logcat.html">logcat</a></li>
          <li><a href="../../../guide/developing/tools/mksdcard.html">mksdcard</a></li>
          <li><a href="../../../guide/developing/tools/monkey.html">Monkey</a></li>
          <li class="toggle-list">
            <div><a href="../../../guide/developing/tools/monkeyrunner_concepts.html">
              <span class="en">monkeyrunner</span>
            </a></div>
            <ul>
              <li><a href="../../../guide/developing/tools/MonkeyDevice.html">
                <span class="en">MonkeyDevice</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyImage.html">
                <span class="en">MonkeyImage</span>
                </a></li>
              <li><a href="../../../guide/developing/tools/MonkeyRunner.html">
                <span class="en">MonkeyRunner</span>
                </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/developing/tools/proguard.html">ProGuard</a></li>
          <li><a href="../../../guide/developing/tools/adb.html#sqlite">sqlite3</a></li>
          <li><a href="../../../guide/developing/tools/traceview.html">Traceview</a></li>
          <li><a href="../../../guide/developing/tools/zipalign.html">zipalign</a></li>
        </ul>
      </li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Publishing</span>
        <span class="de" style="display:none">Veröffentlichung</span>
        <span class="es" style="display:none">Publicación</span>
        <span class="fr" style="display:none">Publication</span>
        <span class="it" style="display:none">Pubblicazione</span>
        <span class="ja" style="display:none">公開</span>
        <span class="zh-CN" style="display:none">发布</span>
        <span class="zh-TW" style="display:none">發佈</span>
    </h2>
    <ul>
      <li><a href="../../../guide/publishing/app-signing.html">
            <span class="en">Signing Your Applications</span>
            <span class="de" style="display:none">Signieren Ihrer Anwendungen</span>
            <span class="es" style="display:none">Firma de aplicaciones</span>
            <span class="fr" style="display:none">Attribution de votre signature <br />à vos applications</span>
            <span class="it" style="display:none">Firma delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションへの署名</span>
            <span class="zh-CN" style="display:none">应用程序签名</span>
            <span class="zh-TW" style="display:none">簽署應用程式</span>
          </a></li>
      <li><a href="../../../guide/publishing/versioning.html">
            <span class="en">Versioning Your Applications</span>
            <span class="de" style="display:none">Versionsverwaltung für Ihre <br />Anwendungen</span>
            <span class="es" style="display:none">Versiones de las aplicaciones</span>
            <span class="fr" style="display:none">Attribution d'une version à vos applications</span>
            <span class="it" style="display:none">Controllo versioni delle applicazioni</span>
            <span class="ja" style="display:none">アプリケーションのバージョニング</span>
            <span class="zh-CN" style="display:none">应用程序版本控制</span>
            <span class="zh-TW" style="display:none">應用程式版本設定</span>
          </a></li>
      <li><a href="../../../guide/publishing/preparing.html">
            <span class="en">Preparing to Publish</span>
            <span class="de" style="display:none">Vorbereitung auf die Veröffentlichung</span>
            <span class="es" style="display:none">Publicación de aplicaciones</span>
            <span class="fr" style="display:none">Préparation à la publication</span>
            <span class="it" style="display:none">Preparativi per la pubblicazione</span>
            <span class="ja" style="display:none">公開の準備</span>
            <span class="zh-CN" style="display:none">准备发布</span>
            <span class="zh-TW" style="display:none">準備發佈</span>
          </a></li>
      <li><a href="../../../guide/publishing/publishing.html">
            <span class="en">Publishing on Android Market</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Best Practices</span>
               <span class="de" style="display:none">Bewährte Verfahren</span>
               <span class="es" style="display:none">Prácticas recomendadas</span>
               <span class="fr" style="display:none">Meilleures pratiques</span>
               <span class="it" style="display:none">Best practice</span>
               <span class="ja" style="display:none">ベスト プラクティス</span>
               <span class="zh-CN" style="display:none">最佳实践</span>
               <span class="zh-TW" style="display:none">最佳實務</span>
    </h2>
    <ul>
      <li><a href="../../../guide/practices/compatibility.html">
            <span class="en">Compatibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/screens_support.html">
          <span class="en">Supporting Multiple Screens</span>
        </a></div>
        <ul>
          <li><a href="../../../guide/practices/screens-distribution.html">
            <span class="en">Distributing to Specific Screens</span>
          </a></li>
          <li><a href="../../../guide/practices/screen-compat-mode.html">
            <span class="en">Screen Compatibility Mode</span>
          </a></li>
          <li><a href="../../../guide/practices/screens-support-1.5.html">
            <span class="en">Strategies for Android 1.5</span>
          </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/optimizing-for-3.0.html">
            <span class="en">Optimizing Apps for Android 3.0</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/ui_guidelines/index.html">
               <span class="en">UI Guidelines</span>
             </a></div>
        <ul>
          <li class="toggle-list">
            <div><a href="../../../guide/practices/ui_guidelines/icon_design.html">
                   <span class="en">Icon Design <span class="new">updated</span></span>
                 </a></div>
            <ul>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_launcher.html">
                    <span class="en">Launcher Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_menu.html">
                    <span class="en">Menu Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_action_bar.html">
                    <span class="en">Action Bar Icons <span class="new">new!</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_status_bar.html">
                    <span class="en">Status Bar Icons <span class="new">updated</span></span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_tab.html">
                    <span class="en">Tab Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_dialog.html">
                    <span class="en">Dialog Icons</span>
                  </a></li>
              <li><a href="../../../guide/practices/ui_guidelines/icon_design_list.html">
                    <span class="en">List View Icons</span>
                  </a></li>
            </ul>
          </li>
          <li><a href="../../../guide/practices/ui_guidelines/widget_design.html">
                <span class="en">App Widget Design <span class="new">updated</span></span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/activity_task_design.html">
                <span class="en">Activity and Task Design</span>
              </a></li>
          <li><a href="../../../guide/practices/ui_guidelines/menu_design.html">
                <span class="en">Menu Design</span>
              </a></li>
        </ul>
      </li>
      </ul>
      <ul>
      <li><a href="../../../guide/practices/design/accessibility.html">
            <span class="en">Designing for Accessibility</span>
          </a></li>
      <li class="toggle-list">
        <div><a href="../../../guide/practices/design/performance.html">
            <span class="en">Designing for Performance</span>
          </a></div>
        <ul>
          <li><a href="../../../guide/practices/design/jni.html">
                <span class="en">JNI Tips</span>
              </a></li>
        </ul>
      </li>
      <li><a href="../../../guide/practices/design/responsiveness.html">
            <span class="en">Designing for Responsiveness</span>
          </a></li>
      <li><a href="../../../guide/practices/design/seamlessness.html">
            <span class="en">Designing for Seamlessness</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Web Applications</span>
    </h2>
    <ul>
      <li><a href="../../../guide/webapps/index.html">
            <span class="en">Web Apps Overview</span>
          </a></li>
      <li><a href="../../../guide/webapps/targeting.html">
            <span class="en">Targeting Screens from Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/webview.html">
            <span class="en">Building Web Apps in WebView</span>
          </a></li>
      <li><a href="../../../guide/webapps/debugging.html">
            <span class="en">Debugging Web Apps</span>
          </a></li>
      <li><a href="../../../guide/webapps/best-practices.html">
            <span class="en">Best Practices for Web Apps</span>
          </a></li>
    </ul>
  </li>

  <li>
    <h2><span class="en">Appendix</span>
               <span class="de" style="display:none">Anhang</span>
               <span class="es" style="display:none">Apéndice</span>
               <span class="fr" style="display:none">Annexes</span>
               <span class="it" style="display:none">Appendice</span>
               <span class="ja" style="display:none">付録</span>
               <span class="zh-CN" style="display:none">附录</span>
               <span class="zh-TW" style="display:none">附錄</span>
    </h2>
    <ul>
      <li><a href="../../../guide/appendix/api-levels.html">
            <span class="en">Android API Levels</span>
          </a></li>
      <li><a href="../../../guide/appendix/install-location.html">
            <span class="en">App Install Location</span>
          </a></li>
      <li><a href="../../../guide/appendix/media-formats.html">
            <span class="en">Supported Media Formats <span class="new">updated</span></span>
          </a></li>
      <li><a href="../../../guide/appendix/g-app-intents.html">
            <span class="en">Intents List: Google Apps</span>
          </a></li>
      <li><a href="../../../guide/developing/tools/aidl.html">AIDL</a></li>
      <li><a href="../../../guide/appendix/glossary.html">
            <span class="en">Glossary</span>
          </a></li>
    </ul>
  </li>

</ul>

<script type="text/javascript">
<!--
    buildToggleLists();
    changeNavLang(getLangPref());
//-->
</script>

      </div>
    </div> <!-- end side-nav -->
    <script>
      addLoadEvent(function() {
        scrollIntoView("devdoc-nav");
        });
    </script>




<div class="g-unit" id="doc-content"><a name="top"></a>

<div id="jd-header" class="guide-header">
  <span class="crumb">
    &nbsp;
    
  </span>
<h1>JNI Tips</h1>
</div>

  <div id="jd-content">

    <div class="jd-descr">
    <div id="qv-wrapper">
<div id="qv">

<h2>In this document</h2>
<ol>
  <li><a href="#JavaVM_and_JNIEnv">JavaVM and JNIEnv</a></li>
  <li><a href="#threads">Threads</a></li>
  <li><a href="#jclass_jmethodID_and_jfieldID">jclass, jmethodID, and jfieldID</a></li>
  <li><a href="#local_and_global_references">Local and Global References</a></li>
  <li><a href="#UTF_8_and_UTF_16_strings">UTF-8 and UTF-16 Strings</a></li>
  <li><a href="#arrays">Primitive Arrays</a></li>
  <li><a href="#region_calls">Region Calls</a></li>
  <li><a href="#exceptions">Exceptions</a></li>
  <li><a href="#extended_checking">Extended Checking</a> </li>
  <li><a href="#native_libraries">Native Libraries</a></li>
  <li><a href="#64_bit">64-bit Considerations</a></li>
  <li><a href="#unsupported">Unsupported Features</a></li>
  <li><a href="#faq_ULE">FAQ: Why do I get <code>UnsatisfiedLinkError</code></a></li>
  <li><a href="#faq_FindClass">FAQ: Why didn't <code>FindClass</code> find my class?</a></li>
  <li><a href="#faq_sharing">FAQ: How do I share raw data with native code?</a></li>
</ol>

</div>
</div>

<p>JNI is the Java Native Interface.  It defines a way for managed code
(written in the Java programming language) to interact with native
code (written in C/C++).  It's vendor-neutral, has support for loading code from
dynamic shared libraries, and while cumbersome at times is reasonably efficient.</p>

<p>You really should read through the
<a href="http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/jniTOC.html">JNI spec for J2SE 6</a>
to get a sense for how JNI works and what features are available.  Some
aspects of the interface aren't immediately obvious on
first reading, so you may find the next few sections handy.
There's a more detailed <a href="http://java.sun.com/docs/books/jni/html/jniTOC.html">JNI Programmer's Guide and Specification</a>.</p>


<a name="JavaVM_and_JNIEnv" id="JavaVM_and_JNIEnv"></a>
<h2>JavaVM and JNIEnv</h2>

<p>JNI defines two key data structures, "JavaVM" and "JNIEnv".  Both of these are essentially
pointers to pointers to function tables.  (In the C++ version, they're classes with a
pointer to a function table and a member function for each JNI function that indirects through
the table.)  The JavaVM provides the "invocation interface" functions,
which allow you to create and destroy a JavaVM.  In theory you can have multiple JavaVMs per process,
but Android only allows one.</p>

<p>The JNIEnv provides most of the JNI functions.  Your native functions all receive a JNIEnv as
the first argument.</p>

<p>The JNIEnv is used for thread-local storage.  For this reason, <strong>you cannot share a JNIEnv between threads</strong>.
If a piece of code has no other way to get its JNIEnv, you should share
the JavaVM, and use <code>GetEnv</code> to discover the thread's JNIEnv. (Assuming it has one; see <code>AttachCurrentThread</code> below.)</p>

<p>The C declarations of JNIEnv and JavaVM are different from the C++
declarations.  The <code>"jni.h"</code> include file provides different typedefs
depending on whether it's included into C or C++.  For this reason it's a bad idea to
include JNIEnv arguments in header files included by both languages.  (Put another way: if your
header file requires <code>#ifdef __cplusplus</code>, you may have to do some extra work if anything in
that header refers to JNIEnv.)</p>

<a name="threads" id="threads"></a>
<h2>Threads</h2>

<p>All threads are Linux threads, scheduled by the kernel.  They're usually
started from managed code (using <code>Thread.start</code>),
but they can also be created elsewhere and then attached to the JavaVM.  For
example, a thread started with <code>pthread_create</code> can be attached
with the JNI <code>AttachCurrentThread</code> or
<code>AttachCurrentThreadAsDaemon</code> functions.  Until a thread is
attached, it has no JNIEnv, and <strong>cannot make JNI calls</strong>.</p>

<p>Attaching a natively-created thread causes a <code>java.lang.Thread</code>
object to be constructed and added to the "main" <code>ThreadGroup</code>,
making it visible to the debugger.  Calling <code>AttachCurrentThread</code>
on an already-attached thread is a no-op.</p>

<p>Android does not suspend threads executing native code.  If
garbage collection is in progress, or the debugger has issued a suspend
request, Android will pause the thread the next time it makes a JNI call.</p>

<p>Threads attached through JNI <strong>must call
<code>DetachCurrentThread</code> before they exit</strong>.
If coding this directly is awkward, in Android 2.0 (Eclair) and higher you
can use <code>pthread_key_create</code> to define a destructor
function that will be called before the thread exits, and
call <code>DetachCurrentThread</code> from there.  (Use that
key with <code>pthread_setspecific</code> to store the JNIEnv in
thread-local-storage; that way it'll be passed into your destructor as
the argument.)</p>


<a name="jclass_jmethodID_and_jfieldID" id="jclass_jmethodID_and_jfieldID"></a>
<h2>jclass, jmethodID, and jfieldID</h2>

<p>If you want to access an object's field from native code, you would do the following:</p>

<ul>
<li> Get the class object reference for the class with <code>FindClass</code></li>
<li> Get the field ID for the field with <code>GetFieldID</code></li>
<li> Get the contents of the field with something appropriate, such as
<code>GetIntField</code></li>
</ul>

<p>Similarly, to call a method, you'd first get a class object reference and then a method ID.  The IDs are often just
pointers to internal runtime data structures.  Looking them up may require several string
comparisons, but once you have them the actual call to get the field or invoke the method
is very quick.</p>

<p>If performance is important, it's useful to look the values up once and cache the results
in your native code.  Because there is a limit of one JavaVM per process, it's reasonable
to store this data in a static local structure.</p>

<p>The class references, field IDs, and method IDs are guaranteed valid until the class is unloaded.  Classes
are only unloaded if all classes associated with a ClassLoader can be garbage collected,
which is rare but will not be impossible in Android.  Note however that
the <code>jclass</code>
is a class reference and <strong>must be protected</strong> with a call
to <code>NewGlobalRef</code> (see the next section).</p>

<p>If you would like to cache the IDs when a class is loaded, and automatically re-cache them
if the class is ever unloaded and reloaded, the correct way to initialize
the IDs is to add a piece of code that looks like this to the appropriate class:</p>

<pre>    /*
     * We use a class initializer to allow the native code to cache some
     * field offsets. This native function looks up and caches interesting
     * class/field/method IDs. Throws on failure.
     */
    private static native void nativeInit();

    static {
        nativeInit();
    }</pre>

<p>Create a <code>nativeClassInit</code> method in your C/C++ code that performs the ID lookups.  The code
will be executed once, when the class is initialized.  If the class is ever unloaded and
then reloaded, it will be executed again.</p>

<a name="local_and_global_references" id="local_and_global_references"></a>
<h2>Local and Global References</h2>

<p>Every argument passed to a native method, and almost every object returned
by a JNI function is a "local reference".  This means that it's valid for the
duration of the current native method in the current thread.
<strong>Even if the object itself continues to live on after the native method
returns, the reference is not valid.</strong>
<p>This applies to all sub-classes of <code>jobject</code>, including
<code>jclass</code>, <code>jstring</code>, and <code>jarray</code>.
(The runtime will warn you about most reference mis-uses when extended JNI
checks are enabled.)</p>
<p>The only way to get non-local references is via the functions
<code>NewGlobalRef</code> and <code>NewWeakGlobalRef</code>.

<p>If you want to hold on to a reference for a longer period, you must use
a "global" reference.  The <code>NewGlobalRef</code> function takes the
local reference as an argument and returns a global one.
The global reference is guaranteed to be valid until you call
<code>DeleteGlobalRef</code>.</p>

<p>This pattern is commonly used when caching a jclass returned
from <code>FindClass</code>, e.g.:</p>
<pre>jclass localClass = env-&gt;FindClass("MyClass");
jclass globalClass = reinterpret_cast&lt;jclass&gt;(env-&gt;NewGlobalRef(localClass));</pre>

<p>All JNI methods accept both local and global references as arguments.
It's possible for references to the same object to have different values.
For example, the return values from consecutive calls to
<code>NewGlobalRef</code> on the same object may be different.
<strong>To see if two references refer to the same object,
you must use the <code>IsSameObject</code> function.</strong>  Never compare
references with <code>==</code> in native code.</p>

<p>One consequence of this is that you
<strong>must not assume object references are constant or unique</strong>
in native code.  The 32-bit value representing an object may be different
from one invocation of a method to the next, and it's possible that two
different objects could have the same 32-bit value on consecutive calls.  Do
not use <code>jobject</code> values as keys.</p>

<p>Programmers are required to "not excessively allocate" local references.  In practical terms this means
that if you're creating large numbers of local references, perhaps while running through an array of
objects, you should free them manually with
<code>DeleteLocalRef</code> instead of letting JNI do it for you.  The
implementation is only required to reserve slots for
16 local references, so if you need more than that you should either delete as you go or use
<code>EnsureLocalCapacity</code>/<code>PushLocalFrame</code> to reserve more.</p>

<p>Note that <code>jfieldID</code>s and <code>jmethodID</code>s are opaque
types, not object references, and should not be passed to
<code>NewGlobalRef</code>.  The raw data
pointers returned by functions like <code>GetStringUTFChars</code>
and <code>GetByteArrayElements</code> are also not objects. (They may be passed
between threads, and are valid until the matching Release call.)</p>

<p>One unusual case deserves separate mention.  If you attach a native
thread with <code>AttachCurrentThread</code>, the code you are running will
never automatically free local references until the thread detaches.  Any local
references you create will have to be deleted manually. In general, any native
code that creates local references in a loop probably needs to do some manual
deletion.</p>

<a name="UTF_8_and_UTF_16_strings" id="UTF_8_and_UTF_16_strings"></a>
<h2>UTF-8 and UTF-16 Strings</h2>

<p>The Java programming language uses UTF-16.  For convenience, JNI provides methods that work with <a href="http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">Modified UTF-8</a> as well.  The
modified encoding is useful for C code because it encodes \u0000 as 0xc0 0x80 instead of 0x00.
The nice thing about this is that you can count on having C-style zero-terminated strings,
suitable for use with standard libc string functions.  The down side is that you cannot pass
arbitrary UTF-8 data to JNI and expect it to work correctly.</p>

<p>If possible, it's usually faster to operate with UTF-16 strings. Android
currently does not require a copy in <code>GetStringChars</code>, whereas
<code>GetStringUTFChars</code> requires an allocation and a conversion to
UTF-8.  Note that
<strong>UTF-16 strings are not zero-terminated</strong>, and \u0000 is allowed,
so you need to hang on to the string length as well as
the jchar pointer.</p>

<p><strong>Don't forget to <code>Release</code> the strings you <code>Get</code></strong>.  The
string functions return <code>jchar*</code> or <code>jbyte*</code>, which
are C-style pointers to primitive data rather than local references.  They
are guaranteed valid until <code>Release</code> is called, which means they are not
released when the native method returns.</p>

<p><strong>Data passed to NewStringUTF must be in Modified UTF-8 format</strong>.  A
common mistake is reading character data from a file or network stream
and handing it to <code>NewStringUTF</code> without filtering it.
Unless you know the data is 7-bit ASCII, you need to strip out high-ASCII
characters or convert them to proper Modified UTF-8 form.  If you don't,
the UTF-16 conversion will likely not be what you expect.  The extended
JNI checks will scan strings and warn you about invalid data, but they
won't catch everything.</p>

<a name="arrays" id="arrays"></a>
<h2>Primitive Arrays</h2>

<p>JNI provides functions for accessing the contents of array objects.
While arrays of objects must be accessed one entry at a time, arrays of
primitives can be read and written directly as if they were declared in C.</p>

<p>To make the interface as efficient as possible without constraining
the VM implementation, the <code>Get&lt;PrimitiveType&gt;ArrayElements</code>
family of calls allows the runtime to either return a pointer to the actual elements, or
allocate some memory and make a copy.  Either way, the raw pointer returned
is guaranteed to be valid until the corresponding <code>Release</code> call
is issued (which implies that, if the data wasn't copied, the array object
will be pinned down and can't be relocated as part of compacting the heap).
<strong>You must <code>Release</code> every array you <code>Get</code>.</strong>  Also, if the <code>Get</code>
call fails, you must ensure that your code doesn't try to <code>Release</code> a NULL
pointer later.</p>

<p>You can determine whether or not the data was copied by passing in a
non-NULL pointer for the <code>isCopy</code> argument.  This is rarely
useful.</p>

<p>The <code>Release</code> call takes a <code>mode</code> argument that can
have one of three values.  The actions performed by the runtime depend upon
whether it returned a pointer to the actual data or a copy of it:</p>

<ul>
    <li><code>0</code>
    <ul>
        <li>Actual: the array object is un-pinned.
        <li>Copy: data is copied back.  The buffer with the copy is freed.
    </ul>
    <li><code>JNI_COMMIT</code>
    <ul>
        <li>Actual: does nothing.
        <li>Copy: data is copied back.  The buffer with the copy
        <strong>is not freed</strong>.
    </ul>
    <li><code>JNI_ABORT</code>
    <ul>
        <li>Actual: the array object is un-pinned.  Earlier
        writes are <strong>not</strong> aborted.
        <li>Copy: the buffer with the copy is freed; any changes to it are lost.
    </ul>
</ul>

<p>One reason for checking the <code>isCopy</code> flag is to know if
you need to call <code>Release</code> with <code>JNI_COMMIT</code>
after making changes to an array &mdash; if you're alternating between making
changes and executing code that uses the contents of the array, you may be
able to
skip the no-op commit.  Another possible reason for checking the flag is for
efficient handling of <code>JNI_ABORT</code>.  For example, you might want
to get an array, modify it in place, pass pieces to other functions, and
then discard the changes.  If you know that JNI is making a new copy for
you, there's no need to create another "editable" copy.  If JNI is passing
you the original, then you do need to make your own copy.</p>

<p>It is a common mistake (repeated in example code) to assume that you can skip the <code>Release</code> call if
<code>*isCopy</code> is false.  This is not the case.  If no copy buffer was
allocated, then the original memory must be pinned down and can't be moved by
the garbage collector.</p>

<p>Also note that the <code>JNI_COMMIT</code> flag does <strong>not</strong> release the array,
and you will need to call <code>Release</code> again with a different flag
eventually.</p>


<a name="region_calls" id="region_calls"></a>
<h2>Region Calls</h2>

<p>There is an alternative to calls like <code>Get&lt;Type&gt;ArrayElements</code>
and <code>GetStringChars</code> that may be very helpful when all you want
to do is copy data in or out.  Consider the following:</p>

<pre>    jbyte* data = env-&gt;GetByteArrayElements(array, NULL);
    if (data != NULL) {
        memcpy(buffer, data, len);
        env-&gt;ReleaseByteArrayElements(array, data, JNI_ABORT);
    }</pre>

<p>This grabs the array, copies the first <code>len</code> byte
elements out of it, and then releases the array.  Depending upon the
implementation, the <code>Get</code> call will either pin or copy the array
contents.
The code copies the data (for perhaps a second time), then calls <code>Release</code>; in this case
<code>JNI_ABORT</code> ensures there's no chance of a third copy.</p>

<p>One can accomplish the same thing more simply:</p>
<pre>    env-&gt;GetByteArrayRegion(array, 0, len, buffer);</pre>

<p>This has several advantages:</p>
<ul>
    <li>Requires one JNI call instead of 2, reducing overhead.
    <li>Doesn't require pinning or extra data copies.
    <li>Reduces the risk of programmer error &mdash; no risk of forgetting
    to call <code>Release</code> after something fails.
</ul>

<p>Similarly, you can use the <code>Set&lt;Type&gt;ArrayRegion</code> call
to copy data into an array, and <code>GetStringRegion</code> or
<code>GetStringUTFRegion</code> to copy characters out of a
<code>String</code>.


<a name="exceptions" id="exceptions"></a>
<h2>Exceptions</h2>

<p><strong>You must not call most JNI functions while an exception is pending.</strong>
Your code is expected to notice the exception (via the function's return value,
<code>ExceptionCheck</code>, or <code>ExceptionOccurred</code>) and return,
or clear the exception and handle it.</p>

<p>The only JNI functions that you are allowed to call while an exception is
pending are:</p>
<ul>
    <li><code>DeleteGlobalRef</code>
    <li><code>DeleteLocalRef</code>
    <li><code>DeleteWeakGlobalRef</code>
    <li><code>ExceptionCheck</code>
    <li><code>ExceptionClear</code>
    <li><code>ExceptionDescribe</code>
    <li><code>ExceptionOccurred</code>
    <li><code>MonitorExit</code>
    <li><code>PopLocalFrame</code>
    <li><code>PushLocalFrame</code>
    <li><code>Release&lt;PrimitiveType&gt;ArrayElements</code>
    <li><code>ReleasePrimitiveArrayCritical</code>
    <li><code>ReleaseStringChars</code>
    <li><code>ReleaseStringCritical</code>
    <li><code>ReleaseStringUTFChars</code>
</ul>

<p>Many JNI calls can throw an exception, but often provide a simpler way
of checking for failure.  For example, if <code>NewString</code> returns
a non-NULL value, you don't need to check for an exception.  However, if
you call a method (using a function like <code>CallObjectMethod</code>),
you must always check for an exception, because the return value is not
going to be valid if an exception was thrown.</p>

<p>Note that exceptions thrown by interpreted code do not unwind native stack
frames, and Android does not yet support C++ exceptions.
The JNI <code>Throw</code> and <code>ThrowNew</code> instructions just
set an exception pointer in the current thread.  Upon returning to managed
from native code, the exception will be noted and handled appropriately.</p>

<p>Native code can "catch" an exception by calling <code>ExceptionCheck</code> or
<code>ExceptionOccurred</code>, and clear it with
<code>ExceptionClear</code>.  As usual,
discarding exceptions without handling them can lead to problems.</p>

<p>There are no built-in functions for manipulating the <code>Throwable</code> object
itself, so if you want to (say) get the exception string you will need to
find the <code>Throwable</code> class, look up the method ID for
<code>getMessage "()Ljava/lang/String;"</code>, invoke it, and if the result
is non-NULL use <code>GetStringUTFChars</code> to get something you can
hand to <code>printf(3)</code> or equivalent.</p>


<a name="extended_checking" id="extended_checking"></a>
<h2>Extended Checking</h2>

<p>JNI does very little error checking. Errors usually result in a crash. Android also offers a mode called CheckJNI, where the JavaVM and JNIEnv function table pointers are switched to tables of functions that perform an extended series of checks before calling the standard implementation.</p>

<p>The additional checks include:</p>

<ul>
<li>Arrays: attempting to allocate a negative-sized array.</li>
<li>Bad pointers: passing a bad jarray/jclass/jobject/jstring to a JNI call, or passing a NULL pointer to a JNI call with a non-nullable argument.</li>
<li>Class names: passing anything but the “java/lang/String” style of class name to a JNI call.</li>
<li>Critical calls: making a JNI call between a “critical” get and its corresponding release.</li>
<li>Direct ByteBuffers: passing bad arguments to <code>NewDirectByteBuffer</code>.</li>
<li>Exceptions: making a JNI call while there’s an exception pending.</li>
<li>JNIEnv*s: using a JNIEnv* from the wrong thread.</li>
<li>jfieldIDs: using a NULL jfieldID, or using a jfieldID to set a field to a value of the wrong type (trying to assign a StringBuilder to a String field, say), or using a jfieldID for a static field to set an instance field or vice versa, or using a jfieldID from one class with instances of another class.</li>
<li>jmethodIDs: using the wrong kind of jmethodID when making a <code>Call*Method</code> JNI call: incorrect return type, static/non-static mismatch, wrong type for ‘this’ (for non-static calls) or wrong class (for static calls).</li>
<li>References: using <code>DeleteGlobalRef</code>/<code>DeleteLocalRef</code> on the wrong kind of reference.</li>
<li>Release modes: passing a bad release mode to a release call (something other than <code>0</code>, <code>JNI_ABORT</code>, or <code>JNI_COMMIT</code>).</li>
<li>Type safety: returning an incompatible type from your native method (returning a StringBuilder from a method declared to return a String, say).</li>
<li>UTF-8: passing an invalid <a href="http://en.wikipedia.org/wiki/UTF-8#Modified_UTF-8">Modified UTF-8</a> byte sequence to a JNI call.</li>
</ul>

<p>(Accessibility of methods and fields is still not checked: access restrictions don't apply to native code.)</p>

<p>There are several ways to enable CheckJNI.</p>

<p>If you’re using the emulator, CheckJNI is on by default.</p>

<p>If you have a rooted device, you can use the following sequence of commands to restart the runtime with CheckJNI enabled:</p>

<pre>adb shell stop
adb shell setprop dalvik.vm.checkjni true
adb shell start</pre>

<p>In either of these cases, you’ll see something like this in your logcat output when the runtime starts:</p>

<pre>D AndroidRuntime: CheckJNI is ON</pre>

<p>If you have a regular device, you can use the following command:</p>

<pre>adb shell setprop debug.checkjni 1</pre>

<p>This won’t affect already-running apps, but any app launched from that point on will have CheckJNI enabled. (Change the property to any other value or simply rebooting will disable CheckJNI again.) In this case, you’ll see something like this in your logcat output the next time an app starts:</p>

<pre>D Late-enabling CheckJNI</pre>




<a name="native_libraries" id="native_libraries"></a>
<h2>Native Libraries</h2>

<p>You can load native code from shared libraries with the standard
<code>System.loadLibrary</code> call.  The
preferred way to get at your native code is:</p>

<ul>
<li> Call <code>System.loadLibrary</code> from a static class
initializer.  (See the earlier example, where one is used to call
<code>nativeClassInit</code>.)  The argument is the "undecorated"
library name, so to load "libfubar.so" you would pass in "fubar".</li>
<li> Provide a native function: <code><strong>jint JNI_OnLoad(JavaVM* vm, void* reserved)</strong></code></li>
<li>In <code>JNI_OnLoad</code>, register all of your native methods.  You
should declare
the methods "static" so the names don't take up space in the symbol table
on the device.</li>
</ul>

<p>The <code>JNI_OnLoad</code> function should look something like this if
written in C++:</p>
<pre>jint JNI_OnLoad(JavaVM* vm, void* reserved)
{
    JNIEnv* env;
    if (vm-&gt;GetEnv(reinterpret_cast&lt;void**&gt;(&env), JNI_VERSION_1_6) != JNI_OK) {
        return -1;
    }

    // Get jclass with env-&gt;FindClass.
    // Register methods with env-&gt;RegisterNatives.

    return JNI_VERSION_1_6;
}</pre>

<p>You can also call <code>System.load</code> with the full path name of the
shared library.  For Android apps, you may find it useful to get the full
path to the application's private data storage area from the context object.</p>

<p>This is the recommended approach, but not the only approach.  Explicit
registration is not required, nor is it necessary that you provide a
<code>JNI_OnLoad</code> function.
You can instead use "discovery" of native methods that are named in a
specific way (see <a href="http://java.sun.com/javase/6/docs/technotes/guides/jni/spec/design.html#wp615">the JNI spec</a> for details), though this is less desirable because if a method signature is wrong you won't know
about it until the first time the method is actually used.</p>

<p>One other note about <code>JNI_OnLoad</code>: any <code>FindClass</code>
calls you make from there will happen in the context of the class loader
that was used to load the shared library.  Normally <code>FindClass</code>
uses the loader associated with the method at the top of the interpreted
stack, or if there isn't one (because the thread was just attached) it uses
the "system" class loader.  This makes
<code>JNI_OnLoad</code> a convenient place to look up and cache class
object references.</p>


<a name="64_bit" id="64_bit"></a>
<h2>64-bit Considerations</h2>

<p>Android is currently expected to run on 32-bit platforms.  In theory it
could be built for a 64-bit system, but that is not a goal at this time.
For the most part this isn't something that you will need to worry about
when interacting with native code,
but it becomes significant if you plan to store pointers to native
structures in integer fields in an object.  To support architectures
that use 64-bit pointers, <strong>you need to stash your native pointers in a
<code>long</code> field rather than an <code>int</code></strong>.


<a name="unsupported" id="unsupported"></a>
<h2>Unsupported Features</h2>

<p>All JNI 1.6 features are supported, with the following exceptions:</p>
<ul>
    <li><code>DefineClass</code> is not implemented.  Android does not use
    Java bytecodes or class files, so passing in binary class data
    doesn't work.</li>
    <li>"Weak global" references are implemented, but may only be passed
    to <code>NewLocalRef</code>, <code>NewGlobalRef</code>, and
    <code>DeleteWeakGlobalRef</code>.  (The spec strongly encourages
    programmers to create hard references to weak globals before doing
    anything with them, so this should not be at all limiting.)</li>
    <li><code>GetObjectRefType</code> (new in JNI 1.6) is implemented but not fully
    functional &mdash; it can't always tell the difference between "local" and
    "global" references.</li>
</ul>

<p>For backward compatibility, you may need to be aware of:</p>
<ul>
    <li>Until Android 2.0 (Eclair), the '$' character was not properly
    converted to "_00024" during searches for method names.  Working
    around this requires using explicit registration or moving the
    native methods out of inner classes.
    <li>Until Android 2.0 (Eclair), it was not possible to use a <code>pthread_key_create</code>
    destructor function to avoid the "thread must be detached before
    exit" check.  (The runtime also uses a pthread key destructor function,
    so it'd be a race to see which gets called first.)
    <li>Until Android 2.2 (Froyo), weak global references were not implemented.
    Older versions will vigorously reject attempts to use them.  You can use
    the Android platform version constants to test for support.
    <li>Until Android 4.0 (Ice Cream Sandwich), JNI local references were
    actually direct pointers. Ice Cream Sandwich added the indirection
    necessary to support better garbage collectors, but this means that lots
    of JNI bugs are undetectable on older releases.
</ul>


<a name="faq_ULE" id="faq_ULE"></a>
<h2>FAQ: Why do I get <code>UnsatisfiedLinkError</code>?</h2>

<p>When working on native code it's not uncommon to see a failure like this:</p>
<pre>java.lang.UnsatisfiedLinkError: Library foo not found</pre>

<p>In some cases it means what it says &mdash; the library wasn't found.  In
other cases the library exists but couldn't be opened by <code>dlopen(3)</code>, and
the details of the failure can be found in the exception's detail message.</p>

<p>Common reasons why you might encounter "library not found" exceptions:</p>
<ul>
    <li>The library doesn't exist or isn't accessible to the app.  Use
    <code>adb shell ls -l &lt;path&gt;</code> to check its presence
    and permissions.
    <li>The library wasn't built with the NDK.  This can result in
    dependencies on functions or libraries that don't exist on the device.
</ul>

<p>Another class of <code>UnsatisfiedLinkError</code> failures looks like:</p>
<pre>java.lang.UnsatisfiedLinkError: myfunc
        at Foo.myfunc(Native Method)
        at Foo.main(Foo.java:10)</pre>

<p>In logcat, you'll see:</p>
<pre>W/dalvikvm(  880): No implementation found for native LFoo;.myfunc ()V</pre>

<p>This means that the runtime tried to find a matching method but was
unsuccessful.  Some common reasons for this are:</p>
<ul>
    <li>The library isn't getting loaded.  Check the logcat output for
    messages about library loading.
    <li>The method isn't being found due to a name or signature mismatch.  This
    is commonly caused by:
    <ul>
        <li>For lazy method lookup, failing to declare C++ functions
        with <code>extern "C"</code> and appropriate
        visibility (<code>JNIEXPORT</code>). Note that prior to Ice Cream
        Sandwich, the JNIEXPORT macro was incorrect, so using a new GCC with
        an old <code>jni.h</code> won't work.
        You can use <code>arm-eabi-nm</code>
        to see the symbols as they appear in the library; if they look
        mangled (something like <code>_Z15Java_Foo_myfuncP7_JNIEnvP7_jclass</code>
        rather than <code>Java_Foo_myfunc</code>), or if the symbol type is
        a lowercase 't' rather than an uppercase 'T', then you need to
        adjust the declaration.
        <li>For explicit registration, minor errors when entering the
        method signature.  Make sure that what you're passing to the
        registration call matches the signature in the log file.
        Remember that 'B' is <code>byte</code> and 'Z' is <code>boolean</code>.
        Class name components in signatures start with 'L', end with ';',
        use '/' to separate package/class names, and use '$' to separate
        inner-class names (<code>Ljava/util/Map$Entry;</code>, say).
    </ul>
</ul>

<p>Using <code>javah</code> to automatically generate JNI headers may help
avoid some problems.


<a name="faq_FindClass" id="faq_FindClass"></a>
<h2>FAQ: Why didn't <code>FindClass</code> find my class?</h2>

<p>Make sure that the class name string has the correct format.  JNI class
names start with the package name and are separated with slashes,
such as <code>java/lang/String</code>.  If you're looking up an array class,
you need to start with the appropriate number of square brackets and
must also wrap the class with 'L' and ';', so a one-dimensional array of
<code>String</code> would be <code>[Ljava/lang/String;</code>.</p>

<p>If the class name looks right, you could be running into a class loader
issue.  <code>FindClass</code> wants to start the class search in the
class loader associated with your code.  It examines the call stack,
which will look something like:
<pre>    Foo.myfunc(Native Method)
    Foo.main(Foo.java:10)
    dalvik.system.NativeStart.main(Native Method)</pre>

<p>The topmost method is <code>Foo.myfunc</code>.  <code>FindClass</code>
finds the <code>ClassLoader</code> object associated with the <code>Foo</code>
class and uses that.</p>

<p>This usually does what you want.  You can get into trouble if you
create a thread yourself (perhaps by calling <code>pthread_create</code>
and then attaching it with <code>AttachCurrentThread</code>).
Now the stack trace looks like this:</p>
<pre>    dalvik.system.NativeStart.run(Native Method)</pre>

<p>The topmost method is <code>NativeStart.run</code>, which isn't part of
your application.  If you call <code>FindClass</code> from this thread, the
JavaVM will start in the "system" class loader instead of the one associated
with your application, so attempts to find app-specific classes will fail.</p>

<p>There are a few ways to work around this:</p>
<ul>
    <li>Do your <code>FindClass</code> lookups once, in
    <code>JNI_OnLoad</code>, and cache the class references for later
    use.  Any <code>FindClass</code> calls made as part of executing
    <code>JNI_OnLoad</code> will use the class loader associated with
    the function that called <code>System.loadLibrary</code> (this is a
    special rule, provided to make library initialization more convenient).
    If your app code is loading the library, <code>FindClass</code>
    will use the correct class loader.
    <li>Pass an instance of the class into the functions that need
    it, by declaring your native method to take a Class argument and
    then passing <code>Foo.class</code> in.
    <li>Cache a reference to the <code>ClassLoader</code> object somewhere
    handy, and issue <code>loadClass</code> calls directly.  This requires
    some effort.
</ul>


<a name="faq_sharing" id="faq_sharing"></a>
<h2>FAQ: How do I share raw data with native code?</h2>

<p>You may find yourself in a situation where you need to access a large
buffer of raw data from both managed and native code.  Common examples
include manipulation of bitmaps or sound samples.  There are two
basic approaches.</p>

<p>You can store the data in a <code>byte[]</code>.  This allows very fast
access from managed code.  On the native side, however, you're
not guaranteed to be able to access the data without having to copy it.  In
some implementations, <code>GetByteArrayElements</code> and
<code>GetPrimitiveArrayCritical</code> will return actual pointers to the
raw data in the managed heap, but in others it will allocate a buffer
on the native heap and copy the data over.</p>

<p>The alternative is to store the data in a direct byte buffer.  These
can be created with <code>java.nio.ByteBuffer.allocateDirect</code>, or
the JNI <code>NewDirectByteBuffer</code> function.  Unlike regular
byte buffers, the storage is not allocated on the managed heap, and can
always be accessed directly from native code (get the address
with <code>GetDirectBufferAddress</code>).  Depending on how direct
byte buffer access is implemented, accessing the data from managed code
can be very slow.</p>

<p>The choice of which to use depends on two factors:</p>
<ol>
    <li>Will most of the data accesses happen from code written in Java
    or in C/C++?
    <li>If the data is eventually being passed to a system API, what form
    must it be in?  (For example, if the data is eventually passed to a
    function that takes a byte[], doing processing in a direct
    <code>ByteBuffer</code> might be unwise.)
</ol>

<p>If there's no clear winner, use a direct byte buffer.  Support for them
is built directly into JNI, and performance should improve in future releases.</p>

    </div>

  <a href="#top" style="float:right">&uarr; Go to top</a>
  
  </div>

<div id="footer">


  <div id="copyright">
    
  Except as noted, this content is licensed under <a
  href="http://www.apache.org/licenses/LICENSE-2.0">Apache 2.0</a>. 
  For details and restrictions, see the <a href="../../../license.html">
  Content License</a>.
  </div>
  <div id="build_info">
    
  Android 4.0&nbsp;r1 - 17 Oct 2011 18:17

  </div>

  <div id="footerlinks">
    
  <p>
    <a href="http://www.android.com/terms.html">Site Terms of Service</a> -
    <a href="http://www.android.com/privacy.html">Privacy Policy</a> -
    <a href="http://www.android.com/branding.html">Brand Guidelines</a>
  </p>
  </div>

</div> <!-- end footer -->

</div><!-- end doc-content -->

</div> <!-- end body-content --> 

<script type="text/javascript">
init(); /* initialize android-developer-docs.js */
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-5831155-1");
pageTracker._trackPageview();
</script>

</body>
</html>



